package com.jzh.selfwallpaper.util;

import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Environment;
import android.view.View;

import java.io.File;
import java.io.FileOutputStream;

public class ScreenShootUtil {

    private Context context;

    public ScreenShootUtil(Context context) {
        this.context = context;
    }


    /**
     * 1 只截取自己应用内部界面
     * 1.1 截取除了导航栏之外的屏幕
     *
     * @param activity
     * @return
     */
    public static Bitmap getScreenShoot1(Activity activity) {
        View dView = activity.getWindow().getDecorView();
        dView.setDrawingCacheEnabled(true);
        dView.buildDrawingCache();
        Bitmap bitmap = Bitmap.createBitmap(dView.getDrawingCache());
        return bitmap;
    }

    /**
     * 1 只截取自己应用内部界面
     * 1.2 截取某个控件或者区域
     * @param dView
     * @return
     */
    public static Bitmap getScreenShoot2(View dView) {

        dView.setDrawingCacheEnabled(true);
        dView.buildDrawingCache();
        Bitmap bitmap = Bitmap.createBitmap(dView.getDrawingCache());
        return bitmap;
    }



}
